package com.xiaofeng.pochi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaofeng.pochi.common.Page;
import com.xiaofeng.pochi.pojo.ShopCartItem;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created with IntelliJ IDEA

 * @Author: chc
 * @Date: 2022/08/26/23:06
 * @Description:
 */
@Component
public interface ShopCartItemMapper extends BaseMapper<ShopCartItem> {

    /**
     * 根据商品ID和创建人查询
     *
     * @param shopCartItem
     * @return
     */
    ShopCartItem getByProductIdAndCreateBy(ShopCartItem shopCartItem);

    /**
     * 更新商品数
     *
     * @param id
     */
    void updateProductCount(@Param("id")Long id, @Param("quantity")Integer quantity);

    /**
     * 添加
     * @param shopCartItem
     */
    void save(ShopCartItem shopCartItem);

    /**
     * 查询当前登录用户的购物车商品数
     * @param username
     * @return
     */
    Integer getProductCountByUser(String username);

    /**
     * 分页查询
     * */
    List<ShopCartItem> getByPage(Page<ShopCartItem> page);

    void deleteByIds(List<Long> ids);

    List<ShopCartItem> getByIds(List<Long> ids);
}
